/**
 * Created on 2007-03-06 23:51
 */
package game;

import java.util.ArrayList;
import java.util.Iterator;

import manager.Manager;

/**
 * @author David Wallin
 */
public class EntityManager extends Manager
{
	public static final EntityManager		INSTANCE = new EntityManager();
	
	private ArrayList<Entity>				m_Entities;
	
	public void addEntity(Entity entity)
	{
		m_Entities.add(entity);
	}
	
	public void removeEntity(Entity entity)
	{
		if(m_Entities.contains(entity))
		{
			m_Entities.remove(entity);
		}
	}
	
	protected void doTearDown()
	{
		m_Entities.clear();
	}
	
	protected void doUpdate(int deltaTime)
	{
		Iterator<Entity> it = m_Entities.iterator();
		
		while(it.hasNext())
		{
			it.next().draw();
		}
	}
	
	private EntityManager()
	{
		m_Entities = new ArrayList<Entity>();
	}
}
